package com.runmi;

import javax.servlet.MultipartConfigElement;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.runmi.webchat.aftersale.interceptor.AuthInterceptor;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

/*
The @SpringBootApplication annotation is equivalent to using
 @Configuration, @EnableAutoConfiguration and @ComponentScan 
 with their default attributes:
*/	
@SpringBootApplication
@EnableSwagger2
@EnableAsync
//@EnableEurekaClient
//@EnableFeignClients
public class App{

	public static void   main(String[] args) {
		SpringApplication.run(App.class, args);
	}
	
	

	
	@Bean
	RestTemplate restTemplate() {
			RestTemplate restTemplate= new RestTemplate();
			SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
	        requestFactory.setReadTimeout(5000);
	        requestFactory.setConnectTimeout(5000);   
	        restTemplate.setRequestFactory(requestFactory);
	        return  restTemplate;
	}	
	
	
	/**  
     * 文件上传配置  
     * @return  
     */  
    @Bean  
    public MultipartConfigElement multipartConfigElement() {  
        MultipartConfigFactory factory = new MultipartConfigFactory();  
        //单个文件最大  
        factory.setMaxFileSize("10240KB"); //10M 
        /// 设置总上传数据总大小  
        factory.setMaxRequestSize("102400KB"); //100M  
        return factory.createMultipartConfig();  
    } 

}

